<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>13.vue中事件修饰符使用</title>
    <style>
        .aa {
            background: red;
            width: 300px;
            height: 300px;
        }
    </style>

</head>
<body>
<div id="app">
    <!--只触发标签自身的事件-->
    <div class="aa" @click.self="divClick">
        <!--阻止事件冒泡-->
        <input type="button" value="按钮" @click.stop="btnClick">
        <input type="button" value="按钮1" @click="btnClick1">
    </div>
    <!--
        .prevent ：用来阻止事件默认的行为
        .once    ：用来只执行一次特定的事件
        -->
    <a href="https://www.baidu.com" @click.prevent.once="aClick">百度</a>

</div>


<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {},
        methods: {
            divClick() {
                alert("div is clicked");
            },
            btnClick() {
                alert('button is clicked');
            },
            btnClick1() {
                alert('button1 is clicked');
            },
            aClick() {
                alert("a is clicked")
            }
        },
        components: {}
    });
</script>
</body>
</html>